<template>
  <div>
    <div class=" mui-card middle">
      <!-- 商品信息 -->
      <div class="goodsinfo" v-for="item in goodsList" :key="item.id">
        <div class="img-con">
          <img :src="item.goods_goods.image" alt="">
        </div>
        <div class="detail">
          <p class="goodsName">{{item.goods_goods.name}}</p>
          <p class="price">
            ￥{{item.price}}
            <strong class="number">x{{item.count}}</strong>
          </p>
        </div>
        
      </div>
      <!-- 订单备注 -->
      <div class="mui-card-content note">
        <div class="title">订单备注</div>
        <p v-if="orderShow.note">{{orderShow.note}}</p>
        <p v-else>(无)</p>
      </div>
      <!-- 配送信息 -->
      <div class="mui-card-content send">
        <div>
          <strong>配送服务</strong>
          <strong>快递运输</strong>
        </div>
        <div>
          <span>中小件送货时间</span>
          <span>工作日、双休日与节假日均可送货</span>
        </div>
      </div>
      <!-- 收货地址 -->
      <div class="mui-card-content address">
        <div class="title">收货地址</div>
        <div>{{orderShow.address_name}} {{orderShow.address_tel}}</div>
        <div>{{orderShow.address_area}} {{orderShow.address_detail}}</div>
      </div>
    </div>

    <div class="mui-card account">
      <p>
        <i>商品金额</i>
        <strong>￥{{orderShow.price}}</strong>
      </p>
      <p>
        <i>运费</i>
        <strong>￥0.00</strong>
      </p>
      <p>
        <s>总价</s>
        <strong>￥{{orderShow.price}}</strong>
      </p>
      <button @click="toPay" class="mui-btn mui-btn-primary">去支付</button>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      orderShow: {},  // orderShow里的有 商品列表 user_order_goods，商品列表里有 图片列表 goods_goods
      goodsList: [], // 商品列表, 里面有图片列表 goods_goods
    }
  },
  created() {
    this.getOrderShow()
  },
  methods: {
    // 获取订单详情
    getOrderShow() {
      this.$http.get('order/show',{params: {id: this.$route.params.id}}).then(res => {
        if (res.data.code === 1) {
          this.orderShow = res.data.data
          this.goodsList = this.orderShow.user_order_goods
          this.imgList = this.goodsList.goods_goods
          console.log(this.orderShow);
        } else if (res.data.code === 2) {
          this.$toast('您未登录，请先登录')
          this.$router.push('/user/login')
        } else {
          this.$toast('订单详情获取失败')
        }
      })
    },
    // 去支付
    toPay() {

    }
  }
}
</script>

<style lang="scss" scoped>
.mui-card {
  padding: 15px;
  margin: 0;
  margin-bottom: 10px;
  .address {
    color: #999;
    div {
      padding-top: 10px;
    }
  }
  .mui-card-content {
    padding-bottom: 3px;
    span {
      padding-right: 15px;
    }
  }
  .goodsinfo {
    display: flex;
    border-bottom: 1px solid #ccc;
    padding: 5px 0;
    .img-con {
      width: 80px;
      img {
        width: 100%;
      }
    }
    .detail {
      width: 100%;
      padding-top: 10px;
      padding-left: 10px;
      font-weight: 700;
      .goodsName {
        color: #000;
        
      }
      .price {
        width: 100%;
        font-size: 16px;
        color: red;
      }
    }
    .number {
      float: right;
      font-weight: 400;
      font-size: 14px;
      color: #999;
    }
  }
  .note {
    border-bottom: 1px solid #ccc;
    p {
      padding-top: 5px;
    }
  }
  .send {
    border-bottom: 1px solid #ccc;
    padding: 10px 0;
    div {
      display: flex;
      justify-content: space-between;
      padding-bottom: 10px;
      span {
        padding-right: 0;
        color: #999;
      }
    }
  }
  .title {
    color: #000;
    padding-top: 10px;
    font-weight: 700;
  }
  textarea {
    font-size: 14px;
  }
  
}
.middle {
  margin-top: 10px;
  padding-left: 10px;
}
.account {
  
  p {
    display: flex;
    justify-content: space-between;
    color: #666;
    i {
      font-style: normal;
    }
    strong {
      font-weight: 500;
      color: red;
      font-size: 16px;
    }
    s {
      text-decoration: none;
      font-weight: 700;
    }
  }
  button {
    width: 100%;
    height: 45px;
    font-size: 16px;
    margin-top: 10px;
  }
}
</style>